<!-- src/components/Breadcrumb.vue -->
<template>
  <el-breadcrumb separator="/">
    <el-breadcrumb-item v-for="(item, index) in breadcrumbs" :key="index" :to="item.path">
      <router-link :to="item.path">{{ item.breadcrumb }}</router-link>
    </el-breadcrumb-item>
  </el-breadcrumb>
</template>

<script setup>
import { computed } from 'vue'
import { useRoute, useRouter } from 'vue-router'

const route = useRoute()
const router = useRouter()

const breadcrumbs = computed(() => {
  let matched = route.matched.filter((item) => item.meta && item.meta.breadcrumb)
  return matched.map((item) => {
    return {
      path: item.path,
      breadcrumb: item.meta.breadcrumb
    }
  })
})
</script>

<style scoped>
.el-breadcrumb {
  margin: 0 20px;
}
</style>
